package itheima.com.mythreadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class MyThreadPoolDemo2 {
    public static void main(String[] args) {
        //参数是最大值而不是默认值（即池子中最多能有十条线程）
        //创建的线程池默认为空，需要给参数
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        ThreadPoolExecutor pool = (ThreadPoolExecutor) executorService;
        //获取线程池数量
        System.out.println(pool.getPoolSize());

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行了");
        });
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行了");
        });
        System.out.println(pool.getPoolSize());

//        executorService.shutdown();
    }
}
